/*
 * Hidden Equity LLC
 * Author: Maksym Fedyay, Kyiv, mcsimf@gmail.com
 * Date: 29.02.2012
 */

package com.hiddenequity.utils;

import android.app.Activity;

import com.hiddenequity.acts.R;

public class ApiErrorHumanizer extends Activity{

	private final static String BID_TOO_HIGH_FOR_DAILY_BUDGET = "BID_TOO_HIGH_FOR_DAILY_BUDGET";
	private final static String DUPLICATE_ADGROUP_NAME = "DUPLICATE_ADGROUP_NAME";
	private final static String DUPLICATE_CAMPAIGN_NAME = "DUPLICATE_CAMPAIGN_NAME";
	private final static String KEYWORD_HAS_INVALID_CHARS = "KEYWORD_HAS_INVALID_CHARS";
	private final static String INCOMPLETE_SIGNUP_USER_INFO_PENDING = "INCOMPLETE_SIGNUP_USER_INFO_PENDING";
	private final static String INCOMPLETE_SIGNUP_USER_INFO_REJECTED = "INCOMPLETE_SIGNUP_USER_INFO_REJECTED";
	public final static String NOT_ADS_USER = "NOT_ADS_USER";
	private final static String INVALID_TOKEN_HEADER = "INVALID_TOKEN_HEADER";
	public final static String GOOGLE_ACCOUNT_COOKIE_INVALID = "GOOGLE_ACCOUNT_COOKIE_INVALID";
	
	public static int humanizeError(String errorString){
		//String result = null;
		if(errorString.contains(BID_TOO_HIGH_FOR_DAILY_BUDGET)){
			return R.string.msg_api_bid_too_high;
		} else if(errorString.contains(DUPLICATE_ADGROUP_NAME)){
			return R.string.msg_api_duplicate_adgroup_name;
		} else if(errorString.contains(DUPLICATE_CAMPAIGN_NAME)){
			return R.string.msg_api_duplicate_campaign_name;
		} else if(errorString.contains(KEYWORD_HAS_INVALID_CHARS)){
			return R.string.msg_api_keyword_invalid_chars;
		} else if(errorString.contains(INCOMPLETE_SIGNUP_USER_INFO_PENDING)){
			return R.string.msg_api_devtoken_pending;
		} else if(errorString.contains(INCOMPLETE_SIGNUP_USER_INFO_REJECTED)){
			return R.string.msg_api_devtoken_rejected;
		}else if(errorString.contains(NOT_ADS_USER)){
			return R.string.msg_api_not_ads_user;
		} else if(errorString.contains(INVALID_TOKEN_HEADER)){
			return R.string.msg_api_devtoken_invalid;
		} else if(errorString.contains(GOOGLE_ACCOUNT_COOKIE_INVALID)){
			return R.string.msg_api_authtoken_invalid;
		} else {
			return 0;
		}
	}
	
	
}
